<!DOCTYPE html>
<html lang="zh-CN">


<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/alwaysblog/favicon_1.ico">
  <link rel="icon" type="image/png" href="/alwaysblog/favicon_1.ico">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="author" content="张小剩">
  
    <meta name="description" content="折腾是一种乐趣，求知是一种追求！">
  
  
    <meta name="keywords" content="软件测试, 自动化测试, 接口自动化测试, UI自动化测试, Python, 前端, js, jquery, javascript, html5, 开发者, 程序猿, 极客, 编程, 代码, 开源, IT网站, Developer, flask, 性能测试, Jmeter, html, css, css3, unittest, pytest, Robot Framework">
  
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <title>张小剩的博客</title>
  <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/5.10.0/css/all.min.css"  >
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"  >
<link rel="stylesheet" href="https://cdn.staticfile.org/mdbootstrap/4.8.7/css/mdb.min.css"  >
<link rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/3.0.1/github-markdown.min.css"  >

<link rel="stylesheet" href="//at.alicdn.com/t/font_1067060_qzomjdt8bmp.css">


  <link rel="stylesheet" href="/alwaysblog/lib/prettify/tranquil-heart.min.css"  >


  <link rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css"  >

<link rel="stylesheet" href="/alwaysblog/css/main.css"  >
<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
  <style type="text/css">
    .banner-bg {
      
        background-image: url('/alwaysblog/static/images/wallhaven-8opx8k.jpg');
      
      background-position: center;
      background-repeat: repeat-y;
      background-size: cover;
      background-attachment: fixed;
    }
  </style>
<meta name="generator" content="Hexo 5.4.1"><link rel="alternate" href="/alwaysblog/atom.xml" title="张小剩的博客" type="application/atom+xml">
</head>

<body class="banner-bg">
  <header style="height: 100vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/alwaysblog/">&nbsp;<strong>张小剩的博客</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/alwaysblog/">主页</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/alwaysblog/archives/">归档</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/alwaysblog/categories/">分类</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/alwaysblog/tags/">标签</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/alwaysblog/links/">友链</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/alwaysblog/about/">关于</a>
          </li>
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>


</nav>

    <div class="view intro-2 rgba-black-slight" id="background">
      <div class="full-bg-img">
        <div class="mask flex-center">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>
            
          </div>
          
            <div class="scroll-down-bar">
              <i class="fa fa-angle-down scroll-down-arrow"></i>
            </div>
          
        </div>
      </div>
    </div>
  </header>
  <main id="mainContent" class="rgba-black-slight">
    
      <div class="container nopadding-md" style="padding-top:0.5rem;padding-bottom:0.5rem;">
        <div class="py-5 z-depth-3" id="board">
          
          <div class="container">
            <div class="row">
              <div class="col-12 col-md-10 m-auto">
                

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/4046588353/" target="_self">
        <p class="h4 index-header">shell 编程</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">shell 实例
echo 用于向窗口输出文本```shell#!/bin/bash

echo “时光静好，岁月安然！”

- 脚本运行
```shell
$ ./test.sh

$  sh test.sh

变量[ 变量名的命名规则 ]

命名只能使用英文字母，数字和下划线，首个字符不能以数字开头
中间不能有空格，可以使用下划线（_）
不能使用标点符号
不能使用bash里的关键字（可用help命令查看保留关键字）


变量赋值```shell#!/bin/bash

string=”从前冬天冷呀 夏天雨呀水呀 秋天远处传来你声音暖呀暖呀”
使用变量echo ${string}
语句给变量赋值 (将 /etc 下目录的文件名循环出来。将文件名 赋值给 file)for file in ls /etc 或 for file in $(ls /etc)    do    echo “文件： ${file}”    done

- **只读变量( readonly  )**
```shell
#!/bin/bash

# 只读变量( readonly  )
base_url=&quot;</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2021-11-02&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;5.8k字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;24分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E5%90%8E%E7%AB%AF%E9%A2%86%E5%9F%9F">后端领域</a>&nbsp;
          
            <a href="/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80">编程语言</a>&nbsp;
          
            <a href="/categories/shell">shell</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/shell">shell</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/2562162005/" target="_self">
        <p class="h4 index-header">python 基础</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">Python 环境搭建
下载安装

$ 下载页面：https://www.python.org/downloads/windows/
    2.7：https://www.python.org/downloads/release/python-2718/（选择：Windows x86-64 MSI installer）
    3.8：https://www.python.org/downloads/release/python-385/（选择：Windows x86-64 executable installer）

    2.7 版本直连：https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi
    3.7 版本直连：https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe


pip 升级

$ python2 -m pip install --upgrade pip --force-reinstall
$ python3 -m pi</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2021-10-02&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;6.1k字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;27分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E5%90%8E%E7%AB%AF%E9%A2%86%E5%9F%9F">后端领域</a>&nbsp;
          
            <a href="/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80">编程语言</a>&nbsp;
          
            <a href="/categories/python">python</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/python">python</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/519960898/" target="_self">
        <p class="h4 index-header">Locust 性能测试</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">Locust 安装及运行
创建虚拟环境，并进入

$ pip install locustio==0.14.6  (0.14.6 版本安装)
$ pip install locust  (最新版本安装)
$
$ 报错： error: Microsoft Visual C++ 14.0 is required. Get it with &quot;Build Tools for Visual Studio&quot;: https://visualstudio.microsoft.com/downloads/ Tools&quot;
$ 解决： http://go.microsoft.com/fwlink/?LinkId=691126
$ 导入win32com模块还失败，执行下面命令
$    python -m pip install pypiwin32


脚本运行

$ locust -f ***.py
    运行成功：
$ (locust_0) D:\Locust\locust_0\src&gt;locust -f locust0-template.py
$ [2020-08-</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2021-08-29&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;642字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;2分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/categories/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95">性能测试</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/tags/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95">性能测试</a>&nbsp;
          
            <a href="/tags/locust">locust</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/3113662073/" target="_self">
        <p class="h4 index-header">性能测试基础</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">性能测试理论知识性能测试的目的：发现性能的瓶颈
负载测试通过逐步加压的方法，达到既定的性能阀值的目标。
    阀值的设定应是小于等于某个值,如 CPU 的使用率小于等于 80%

压力测试通过逐步加压的方法，使系统的某些资源达到饱和，甚至失效的状态（也就是说什么条件下可以把系统压崩溃）

并发测试同一时间内，多个虚拟用户同时访问同一模块、同一功能。通常的测试方法是设置集合点。

容量测试通常是指数据库层面的，目标是获取数据库最佳容量的能力，又称为容量预估。
    测试方法：在一定的并发用户，不同的基础数据量下，观察数据库的处理能力，即获取数据库的各项性能指标

可靠性测试（稳定性测试 / 疲劳测试）系统在高压的情况下，长时间的运行系统是否稳定。
    如 CPU 使用率在 80% 以上，7 * 24 小时运行，系统是否稳定

异常测试（失败测试）指系统架构方面的测试，如：在负载均衡架构中，要测试宕机（死机）、节点挂掉等情况下系统的反应。

性能测试指标定义
事务

从客户端发起的一个或多个请求(这些请求组成一个完整的操作)，到客户端接收到从服务器返回的响应。


TPS (Tra</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2021-08-18&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;5.8k字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;22分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/categories/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95">性能测试</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/tags/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95">性能测试</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/3888393026/" target="_self">
        <p class="h4 index-header">Robot Framework</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">特点

提供可视化界面 ride、 eclipse
txt、html 等格式编写测试用例，而不是编程语言
支持关键字驱动（直接调用已有的关键字，组成自动化用例）
支持 web 、app、api 自动化测试
开源，基于 Python 编写

Robot Framework 环境搭建
安装 wxPython

$ 下载页面： http://wxpython.org/download.php#stable
    在选择版本下载的时候要注意选择与 Python 版本对应的版本，并且选择 unicode 版本。
    比如版本：wxPython2.8-win64-unicode-py27.exe，否则安装完成后不能支持中文。
    下载完成后，选择默认项进行安装即可。


安装 Robot Framwork

$    pip install robotframwork
    图形化界面：RIDE
        pip install robotframework-ride
        pip install robotframework-ride==1.7.4.1（指定版本安装）</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2021-05-11&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;1.5k字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;6分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/categories/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95">自动化测试</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/tags/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%EF%BC%8CRobot%20Framework">自动化测试，Robot Framework</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/3157456672/" target="_self">
        <p class="h4 index-header">测试用例设计</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">测试用例设计qq⽂件传输测试⽤例
传输成功


⽂件直接拖到对话框，点击发送
点击传送⽂件按钮，选择⽂件，点击发送
传送汇总显示进度条
传送显示⽂件名字，以及⽂件⼤⼩
给⼀个⽤户传输多个⽂件
同时给不同⽤户传输⽂件（相同⽂件和不同⽂件)
本地打开的时候，可以传送⽂件
接收成功的默认路径
⽂件接收后，是否正常
是否可以更改保存路径
⽂件传输时，不影响其他功能
接收⽅在线，不在线，离线⽂件，好友，⾮好友（临时会话）


传输失败


点击取消，可以取消⽂件发送
接收⽅，拒绝接收
直接关闭对话框，有提示，有⽂件在传输
⽂件-⽂件夹，⽂件夹多层，空⽂件
⽂件⼤⼩的边界值


⽂件名称


普通⽂件
含有特殊符号的⽂件
⽂件名空，空格，纯中⽂，中英混合，纯英⽂，含有标点符号


⽂件格式


exe⽂件，txt，doc，pdf等
图⽚、视频、⾳频、压缩⽂件、⽂件夹、病毒⽂件


界⾯测试


界⾯美观、易⽤
按钮位置符合规范以及正确
提示语是否正确


其他测试


弱⽹情况传输
上传中断⽹
上传⽂件，把源⽂件删除

一个有广告的纸杯子，请设计测试用例？
测试项目：杯子
需求测试：查看杯子使用说</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2021-01-12&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;2.4k字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;8分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95">软件测试</a>&nbsp;
          
            <a href="/tags/%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B">测试用例</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/1564283385/" target="_self">
        <p class="h4 index-header">linux 命令总结</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">[ 命令格式 ]

命令 [ 选项 ][ 参数 ]
例： ls -la /home

目录处理命令
ls

原意： list
功能： 显示目录文件
选项： -a： 显示所有文件(all)，-l： 显示详细信息(long)
参数： 路径（非必填）
语法： ls -la /home


cd

原意： change directory
功能： 切换目录
参数： 路径
语法： cd /home (绝对路径) 或者 cd admin (相对路径)


pwd

原意： print working directory
功能： 显示当前目录
语法： pwd


mkdir

原意： make directories
功能： 创建空目录
选项： -p： 递归创建(可以创建不存在的目录，如： /home/admin/document/work)
参数： 目录名
语法： mkdir -p [目录名]


cp

原意： copy
功能： 复制文件或目录
选项： -r： 复制目录，-p： 保留文件属性 copy(保留创建时间等)
参数： [原文件或目录][目标目录]
语法： cp -rp [原文件或目录]</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2020-11-02&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;1.6k字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;6分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F">操作系统</a>&nbsp;
          
            <a href="/categories/Linux">Linux</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/linux">linux</a>&nbsp;
          
            <a href="/tags/linux%20%E5%91%BD%E4%BB%A4">linux 命令</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/4065722285/" target="_self">
        <p class="h4 index-header">docker</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">Docker 安装
通过 uname -r 命令查看你当前的内核版本$ uname -r




root权限更新Yum包
$ yum update


卸载旧版本：（如果安装过旧版本的话）(旧版名称是docker , 最新社区版 docker-engine， 目前已改名为docker-ce )
$ yum -y remove docker docker-common docker-selinux docker-engine


设置Yum源：（本文以Yum安装为例子进行安装）



安装 yum-utils , 使用 yum-config-manager 工具设置Yum源, 后面两个是 devicemapper驱动依赖
$ yum install -y yum-utils device-mapper-persistent-data lvm2


执行以下命令，添加docker的yum源
 $ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
 # 此处可能会报错 </div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2020-10-17&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;739字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;3分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E5%89%8D%E6%B2%BF%E6%8A%80%E6%9C%AF">前沿技术</a>&nbsp;
          
            <a href="/categories/Docker">Docker</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/docker">docker</a>&nbsp;
          
            <a href="/tags/%E5%AE%B9%E5%99%A8">容器</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/2689587330/" target="_self">
        <p class="h4 index-header">MySQL 刷题记录</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">组合两个表表1: Person
+-------------+---------+
| 列名         | 类型     |
+-------------+---------+
| PersonId    | int     |
| FirstName   | varchar |
| LastName    | varchar |
+-------------+---------+
PersonId 是上表主键

表2: Address
+-------------+---------+
| 列名         | 类型    |
+-------------+---------+
| AddressId   | int     |
| PersonId    | int     |
| City        | varchar |
| State       | varchar |
+-------------+---------+
AddressId 是上表主键

编写一个 SQL 查询，满足条件：无论 person 是否有地址信息，都需要基于上述两表提供 person </div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2020-10-13&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;706字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;3分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E5%90%8E%E7%AB%AF%E9%A2%86%E5%9F%9F">后端领域</a>&nbsp;
          
            <a href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93">数据库</a>&nbsp;
          
            <a href="/categories/MySQL">MySQL</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/mysql">mysql</a>&nbsp;
          
            <a href="/tags/leetcode">leetcode</a>&nbsp;
          
            <a href="/tags/%E7%89%9B%E5%AE%A2">牛客</a>&nbsp;
          
        
      </div>
    </div>
  </div>

  <div class="row mb-4 mx-auto">
    
    
      <div class="col-12 col-md-12 m-auto">
    
      <a href="/alwaysblog/post/4225305543/" target="_self">
        <p class="h4 index-header">MySQL 经典面试题</p>
        
        
          
        
        <div class="index-excerpt" >
          <div class="index-text mb-1">取得每个部门最高薪水的人员名称-- 分析
-- 第一步： 求出每个部门最高的薪水
SELECT 
    e.deptno,MAX(e.sal) as maxsal
FROM emp e
GROUP BY 
    e.deptno;
-- 将以上查询结果当成一个临时表 t(deptno,maxsal)

-- 最高薪水的人员名称（两张表的连接）
SELECT 
    e.deptno,e.ename,t.maxsal,e.sal
FROM 
    (SELECT e.deptno,MAX(e.sal) AS maxsal 
     FROM emp e 
     GROUP BY e.deptno;) t
JOIN emp e ON t.deptno = e.deptno
WHERE t.maxsal = e.sal 
ORDER BY e.deptno;

那些人的薪水在部门的平均薪水之上-- 分析 
-- 第一步，求出部门的平均薪水
SELECT 
    e.deptno, AVG(e.sal) AS avgsal
FROM 
    emp e
GROUP BY e.</div>
        </div>
      </a>
      <div>
        
          <i class="iconfont icon-riqi2"></i>&nbsp;2020-09-01&nbsp;&nbsp;
        
        
        <i class="far fa-chart-bar"></i>&nbsp;248字&nbsp;&nbsp;
        <i class="far fa-clock"></i>&nbsp;1分钟&nbsp;&nbsp;
        
        
          <i class="iconfont icon-inbox"></i>
          
            <a href="/categories/%E5%90%8E%E7%AB%AF%E9%A2%86%E5%9F%9F">后端领域</a>&nbsp;
          
            <a href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93">数据库</a>&nbsp;
          
            <a href="/categories/MySQL">MySQL</a>&nbsp;
          &nbsp;
        
        
          <i class="iconfont icon-tag"></i>
          
            <a href="/tags/mysql">mysql</a>&nbsp;
          
        
      </div>
    </div>
  </div>


  <nav aria-label="index posts navigation Page">
    <span class="pagination pg-blue justify-content-center mt-5">
      <a class="extend prev" rel="prev" href="/alwaysblog/"><i class="fas fa-angle-double-left"></i></a><a class="page-number" href="/alwaysblog/">1</a><span class="page-number current">2</span><a class="page-number" href="/alwaysblog/page/3/">3</a><a class="page-number" href="/alwaysblog/page/4/">4</a><a class="extend next" rel="next" href="/alwaysblog/page/3/"><i class="fas fa-angle-double-right"></i></a>
    </span>
  </nav>
  
    <script type="text/javascript">$(".pagination a").each(function(){$(this)[0].href+="#board";})</script>
  


              </div>
            </div>
          </div>
        </div>
      </div>
    
  </main>
  
<div id="sidebar" class="sidebar-hide">
  <span class="sidebar-button sidebar-button-shift" id="toggle-sidebar" >
    <i class="fa fa-arrow-right on" aria-hidden="true"></i>
  </span>
  <div class="sidebar-overlay"></div>
  <div class="sidebar-intrude">
    <div class="sidebar-avatar">
      <img src="/alwaysblog/static/images/avatar.jpg" srcset="/alwaysblog/static/images/avatar.jpg" alt="avatar"/>
    </div>
    <div class="text-center sidebar-about">
      <p class="h3 sidebar-author">张小剩</p>
      <p class="sidebar-subtitle">One two one ... <script type='text/javascript'>console.log('博主认证: https://bbs.liyuans.com')</script></p>
      
        <a href="https://github.com/alwayscn" class="h4" target="_blank">
          <i class="fab fa-github" aria-hidden="true"></i>
        </a>
        &nbsp;&nbsp;
      
        <a href="https://www.yuque.com/extime/blog" class="h4" target="_blank">
          <i class="fab fa-twitter" aria-hidden="true"></i>
        </a>
        &nbsp;&nbsp;
      
        <a href="https://www.cnblogs.com/wehome" class="h4" target="_blank">
          <i class="fab fa-blog" aria-hidden="true"></i>
        </a>
        &nbsp;&nbsp;
      
        <a href="mailto:zhangxy.cn@gmail.com" class="h4" target="_blank">
          <i class="fas fa-envelope" aria-hidden="true"></i>
        </a>
        &nbsp;&nbsp;
      
    </div>
    <div class="sidebar-friend">
<!--       <p class="h6 sidebar-friend-title"> -->
<!--         <span class="sidebar-label-left"><i class="fas fa-user-friends"></i></span> -->
<!--         <span class="sidebar-label">友情链接</span> -->
<!--       </p> -->
      <ul class="list-group">
        
          <a href="https://console.leancloud.app/" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              LeanCloud
            </li>
          </a>
        
          <a href="https://vercel.com/" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              Vercel
            </li>
          </a>
        
          <a href="https://hitokoto.cn/" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              一言
            </li>
          </a>
        
          <a href="https://zty.pe/" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              打字游戏
            </li>
          </a>
        
          <a href="https://flipanim.com/" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              在线涂鸦
            </li>
          </a>
        
          <a href="http://gogoame.sumbioun.com/" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              Gogoame (午後雨)
            </li>
          </a>
        
          <a href="https://hin.cool/c/dd.html" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              减压滑碟
            </li>
          </a>
        
          <a href="https://www.jq22.com/yanshi4710" target="_blank">
            <li class="list-group-item">
              <i class="fas fa-quote-left"></i>&nbsp;
              元素周期
            </li>
          </a>
        
    </ul>
    </div>
  </div>
</div>


  
    <a class="z-depth-1" id="scroll-top-button" href="#" role="button">
      <i class="fa fa-chevron-up scroll-top-arrow" aria-hidden="true"></i>
    </a>
  
  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  
  <div id="footerContent"  class="rgba-black-slight">
<footer>
  <div class="footer-plane">
      <div class="blog_music">
        <script src="//music.clwl.online/Player/player.min.js" id="SinKingMusic" key="765"></script>
      </div>
      <div class="footer-container">

        <div class="footer-left">
            <div>
            <!-- 版权信息 -->
            
            <div class="footer-info">
                
                  Copyright © 2023&nbsp;张小剩.Powered by
                 <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener noreferrer">
                  Fluid
                 </a>
                
            </div>
            
            <!-- 备案信息 -->
            
            </div>

        </div>
        <div class="footer-details footer-right">
            <div>
                
                <div class="footer-aside-box">
                    <i class="fa fa-cog fa-spin"></i>
                    <span id="span">本站已稳定运行: 128天11小时56分5秒</span>
                    <script type="text/javascript">
                        function runtime() {
                            // 初始时间，日/月/年 时:分:秒
                            // X = new Date("09/27/2021 07:21:00");
                            console.log("12/12/2021 07:21:00")
                            X = new Date("12/12/2021 07:21:00");
                            Y = new Date();
                            T = (Y.getTime() - X.getTime());
                            M = 24 * 60 * 60 * 1000;
                            a = T / M;
                            A = Math.floor(a);
                            b = (a - A) * 24;
                            B = Math.floor(b);
                            c = (b - B) * 60;
                            C = Math.floor((b - B) * 60);
                            D = Math.floor((c - C) * 60);
                            //信息写入到DIV中
                            span.innerHTML = "本站已稳定运行: " + A + " 天" + B + " 小时" + C + " 分" + D
                             + " 秒"
                        }

                        setInterval(runtime, 1000);
                    </script>
                </div>
                

                
            </div>
      </div>
      </div>
      <!-- 一言 -->
      
          <div class="footer-hitokoto">
            <a id="hitokotoa" href="#" target="_blank" rel="nofollow noopener noreferrer">
              <span id="hitokoto"></span>
            </a>
          </div>
      
  </div>
</footer>
</div>
<!-- SCRIPTS -->
<script src="/alwaysblog/lib/popper/popper.min.js" ></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js" ></script>
<script src="https://cdn.staticfile.org/mdbootstrap/4.8.7/js/mdb.min.js" ></script>
<script src="/alwaysblog/js/main.js" ></script>

  <script src="/alwaysblog/js/lazyload.js" ></script>


<!-- Plugins -->

  <script src="/alwaysblog/lib/prettify/prettify.min.js" ></script>
  <script type="text/javascript">
    $(document).ready(function () {
      $('pre').addClass('prettyprint  linenums');
      prettyPrint();
    })
  </script>


  <script src="https://cdn.staticfile.org/typed.js/2.0.9/typed.min.js" ></script>
  <script type="text/javascript">
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "折腾是一种乐趣，求知是一种追求！&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>


  <script src="https://cdn.staticfile.org/anchor-js/4.2.0/anchor.min.js" ></script>
  <script type="text/javascript">
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>


  <script src="/alwaysblog/js/local-search.js" ></script>
  <script type="text/javascript">
    var path = "/alwaysblog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      getSearchFile(path);
      this.onclick = null
    }
  </script>



  

  
    <!-- MathJax -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
          tex2jax: {
              inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
              processEscapes: true,
              skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
          }
      });

      MathJax.Hub.Queue(function() {
          var all = MathJax.Hub.getAllJax(), i;
          for(i=0; i < all.length; i += 1) {
              all[i].SourceElement().parentNode.className += ' has-jax';
          }
      });

    </script>

    <script src="https://cdn.staticfile.org/mathjax/2.7.6/MathJax.js?config=TeX-MML-AM_CHTML" ></script>

  





  <script type="text/javascript">
  /*一言API*/
  $(document).ready(function(){getHitokoto();});
  function hitokoto(e) {
    $("#hitokoto").stop().fadeOut(function() {
      $("#hitokoto").html(e.hitokoto);
      var element = document.getElementById('hitokotoa');
      element.href = "https://hitokoto.cn/?uuid=" + e.uuid;
      $("#hitokoto").stop().fadeIn();
    })
  };
  function getHitokoto() {
    var e = ["a", "b", "c", "d", "e", "i"];
    fetch('https://v1.hitokoto.cn/?encode=json&charset=utf-8&c=' + e[Math.floor(Math.random() * e.length)], {cache: 'no-cache', method: 'GET', mode: 'cors'}).then(response => response.json()).then(data => {
      hitokoto(data);
      setTimeout(getHitokoto, 1e4);
    }).catch(console.error)
  };
  </script>




<!-- Functions -->
<script type="text/javascript">
  /* 切换背景 */
  
  $("#background").removeClass("banner-bg");
  $("body").addClass("banner-bg");
  var postToTopHight = $("#board").offset().top;
  $(window).scroll(function () {
    var bgDisplay = false;
    var scrollHeight = document.body.scrollTop + document.documentElement.scrollTop;
    bgDisplay = scrollHeight >= postToTopHight;
    if(bgDisplay) {
      $('#background').removeClass("rgba-black-slight");
      $('#mainContent').removeClass("rgba-black-slight");
      $('#footerContent').removeClass("rgba-black-slight");
    } else {
      $('#background').addClass("rgba-black-slight");
      $('#mainContent').addClass("rgba-black-slight");
      $('#footerContent').addClass("rgba-black-slight");
    }
  });
  
</script>

  <script type="text/javascript">
    /*显示博客运行时间*/
    var blogRunTime = function () {
      var runTime = document.getElementById("runtime");
      var runtimeDate = "12/12/2021 07:21:00";
	    var createDate = new Date(runtimeDate);
	    var nowDate = new Date();
	    var dateLine = nowDate.getTime() - createDate.getTime();
	    var runDate = Math.floor(dateLine / (1000 * 60 * 60 * 24));
	    runTime.innerHTML = runDate;
    };
    $(document).ready(function(){
	    blogRunTime();
    });
  </script>


  <script type="text/javascript">
    /*窗口监视*/
    var originalTitle = document.title;
    window.onblur = function(){document.title = "你不爱我了QAQ"};
    window.onfocus = function(){document.title = originalTitle};
  </script>


  <script type="text/javascript">
    /* 雪花效果 */
    console.log('雪花效果 code by kvv.me');
    ~function () {
      function t() {
          e.width = window.innerWidth,
          e.height = window.innerHeight,
          o = Math.round(window.innerWidth * window.innerHeight / 1e4)
      }
      function n() {
          var t = window.innerWidth
            , d = window.innerHeight
            , c = e.getContext("2d");
          c.clearRect(0, 0, t, d),
          c.fillStyle = "rgba(255, 255, 255, 0.7)",
          c.beginPath(),
          a += .01;
          for (var u = 0; o > u; u++) {
            var l = r[u];
            if (!l) {
              continue
            }
            ;c.moveTo(l.x, l.y),
            c.arc(l.x, l.y, l.radius, 0, 2 * Math.PI, !0),
            l.y += Math.cos(a) + l.radius / 2,
            l.x += Math.sin(a * l.direction),
            (l.x > t + 5 || -5 > l.x || l.y > d) && (u % 3 > 0 ? (r[u].x = Math.random() * t,
            r[u].y = -10) : Math.sin(a * l.direction) > 0 ? (r[u].x = -5,
            r[u].y = Math.random() * d) : (r[u].x = t + 5,
            r[u].y = Math.random() * d))
          }
          c.fill(),
          i(n)
      }
      var e = document.createElement("canvas")
        , i = requestAnimationFrame || msRequestAnimationFrame || function(t) {
          setTimeout(t, 16)
        }
      , a = 0
      , o = 0
      , r = [];
      t(),
      e.className = "snow",
      document.body.appendChild(e);
      for (var d = 0; o > d; d++)
        r.push({
            x: Math.random() * window.innerWidth,
            y: Math.random() * window.innerHeight,
            radius: 4 * Math.random() + 1,
            direction: 2 * Math.random() - .5
        });
      addEventListener("resize", t),
      i(n)
    }();
  </script>


  <script type="text/javascript">
    /* 评论自动跳转 */
    var jumpComments = function(){
      if(window.location.hash){
        var hash_decode = decodeURI(window.location.hash);
        if(!$(hash_decode).length){
          var checkExist = setInterval(function() {
            if ($(hash_decode).length) {
              clearInterval(checkExist);
              setTimeout(function(){
                $('html, body').animate({scrollTop: $(hash_decode).offset().top-90}, 1000);
              }, 1500);
            }
          }, 100);
        }
      }
    }
    $(document).ready(function(){
	    jumpComments();
    });
  </script>

 
 
 
 

<!-- cnzz -->
<style type="text/css">#cnzz_stat_icon_1258664352{display: none;}</style>
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1258664352'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s4.cnzz.com/z_stat.php%3Fid%3D1258664352' type='text/javascript'%3E%3C/script%3E"));</script>
 

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-150991779-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag("js", new Date());
  gtag("config", "UA-150991779-1");
</script>
 

  
    <script type="text/javascript">
      /* 页面 banner 覆盖全屏 */
      $(".scroll-down-bar .scroll-down-arrow").css({"margin-top":"3rem"});
      $("#board").css({"margin-top":"0"});
    </script>
  
</body>
</html>